basename
Files Timm Sandbox Mar10 Revised

Accessing the File Name at the End of a Path Name

Problem
=======

Given a pathname, extract the filename at the very end.

Solution
========

 function basename(path,  n,tmp) {
	n = split(path,tmp,/\//)
	return tmp[n]
 }

    function Basename(    s) {
	print basename("/home/timm/tmp/fred") == "fred"
    }   

Discussion
==========

Assumes that the pathname is separated by a slash. This works on UNIX-style file systems
(including Macs, after version 10.0).

Author
======

Tim Menzies

